<template>
	<view>
		<view class="goods_box">
			<image :src="info.images.file_path" style="width: 100%;height: 400rpx;" mode="aspectFill"></image>
			<scroll-view class="goods_boom" scroll-x="true">
				<view class="goods-list" :class="{goods_active: btn_status == index}" @click="changeClass(index,item)"
					v-for="(item,index) in info.shuju.data">
					{{item.product_name}}
					<view style="display: flex;margin-top: 20rpx;height: 40rpx;line-height: 40rpx;">
						<view style="color: red;font-size: 30rpx;">
							￥{{item.product_price}}
						</view>
						<view style="color: #ccc;font-size: 26rpx;text-decoration:line-through;margin-left: 20rpx;">
							￥{{item.line_price}}
						</view>
					</view>
				</view>
			</scroll-view>
			<view style="padding: 20rpx;color: #B7B7B7;">
				<!-- 已服务：{{product_detail.product_salesd}}单 -->
				已服务：80000+单
			</view>
			<view class="hr"></view>
			<view style="color: #E96725;padding: 20rpx;display: flex;">
				<image style="width: 40rpx;height: 40rpx;margin-right: 10rpx;vertical-align: middle;"
					src="https://jiechendy.sdshengyue.cn/uploads/d1/f34a7214907ba5d37666d94c6cc12e.png"></image>免费取送
			</view>

		</view>
		<view class="goods_detail">
			<!-- <view class="title">团购详情</view> -->
			<view class="fenlei">
				<view class="father" v-for="(item,index) in categoryData">
					<view class="son" :class="{son_active: btn_status1 == index}"
						@click="change(index,item.category_id)">
						{{item.name}}
					</view>
					<view :class="{xian_active: btn_status1 == index}">

					</view>
				</view>
			</view>

			<!-- <view class="hr1"></view> -->
			<view class="hr2"></view>
			<view class="detail_box" v-if="show_box == true">
				<view class="txt">服务流程</view>
				<view style="width: 100%;display: flex;">
					<view class="order_box">下单服务</view>
					<view class="order_box_dyh">
						<image :src="dyh" style="width: 30rpx;height: 30rpx;" mode="aspectFit"></image>
					</view>
					<view class="order_box">在线预约</view>
					<view class="order_box_dyh">
						<image :src="dyh" style="width: 30rpx;height: 30rpx;" mode="aspectFit"></image>
					</view>
					<view class="order_box">上门取件</view>
					<view class="order_box_dyh">
						<image :src="dyh" style="width: 30rpx;height: 30rpx;" mode="aspectFit"></image>
					</view>
					<view class="order_box">商家服务</view>
					<view class="order_box_dyh">
						<image :src="dyh" style="width: 30rpx;height: 30rpx;" mode="aspectFit"></image>
					</view>
					<view class="order_box">送货上门</view>
				</view>
				<view class="txt">服务内容</view>
				<view style="display: flex;margin: 10rpx 0;">
					<view class="shop_name">商品名称</view>
					<view class="shop_detail">{{product_detail.product_name}}</view>
				</view>
				<view style="display: flex;margin: 10rpx 0;">
					<view class="shop_name">衣物种类</view>
					<view class="shop_detail">{{product_detail.zhonglei}}</view>
				</view>
				<view style="display: flex;margin: 10rpx 0;">
					<view class="shop_name">服务时效</view>
					<view class="shop_detail">{{product_detail.shoptimi}}</view>
				</view>
				<view class="txt">注意事项</view>
				<view style="display: flex;margin: 10rpx 0;">
					<view class="shop_name">服务范围</view>
					<view class="shop_detail">{{product_detail.fanwei}}</view>
				</view>
				<view style="display: flex;margin: 10rpx 0;">
					<view class="shop_name">服务不含</view>
					<view class="shop_detail">{{product_detail.buhan}}</view>
				</view>
				<view style="display: flex;margin: 10rpx 0;">
					<view class="shop_name">退款说明</view>
					<view class="shop_detail">{{product_detail.shuoming}}
					</view>
				</view>
				<view class="txt">产品详情</view>
				<view v-if="product_detail.is_picture == 0" class="content-box" v-html="product_detail.content"></view>
				<view v-if="product_detail.is_picture == 1" class="content-box">
					<view class="ww100" v-for="(item, index) in product_detail.contentImage" :key="index">
						<image class="ww100" :src="item.file_path" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="detail_box" v-else>
				<view class="comment-list" style="padding: 0;">
					<view v-if="tableData.length !=0 " style="padding: 30rpx 0;" v-for="(item, index) in tableData"
						:key="index">
						<view class="cmt-user" style="margin-bottom: 40rpx;">
							<view class="left">
								<image class="photo" :src="item.users.avatarUrl" mode="aspectFill"></image>
								<view class="name">
									<view>{{ item.users.nickName }}</view>
									<view v-if="item.score == 10" class="eval" style="display: flex;">
										<i :key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i>
									</view>
									<view v-if="item.score == 20" class="eval" style="display: flex;">
										<i :key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start' : 'icon iconfont icon-start'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start1' : 'icon iconfont icon-start1'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start1' : 'icon iconfont icon-start1'"></i>
									</view>
									<view v-if="item.score == 30" class="eval" style="display: flex;">
										<i :key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start1' : 'icon iconfont icon-start1'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start1' : 'icon iconfont icon-start1'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start1' : 'icon iconfont icon-start1'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start1' : 'icon iconfont icon-start1'"></i><i
											:key="indexEv"
											:class="itemEv ? 'icon iconfont icon-start1' : 'icon iconfont icon-start1'"></i>
									</view>

								</view>
								<view style="font-size: 26rpx;color: #ccc;margin-left: 120rpx;">{{ item.create_time }}
								</view>
							</view>
						</view>
						<!-- 						<view class="d-b-c p20">
							<view class="d-s-c">
								<view v-if="item.score == 10" class="d-c-c mr20">
									<text class="icon iconfont icon-pingjiahaoping"></text>
									<text class="ml10 gray9">好评</text>
								</view>
								<view v-if="item.score == 20" class="d-c-c mr20">
									<text class="icon iconfont icon-pingjiazhongping"></text>
									<text class="ml10 gray9">中评</text>
								</view>
								<view v-if="item.score == 30" class="d-c-c mr20">
									<text class="icon iconfont icon-pingjiachaping"></text>
									<text class="ml10 gray9">差评</text>
								</view>
							</view>
							<text class="datetime gray9">{{ item.create_time }}</text>
						</view> -->
						<view style="margin: 10rpx 0;" class="p-0-20 f24 gray3">{{ item.content }}</view>
						<view class="imgs d-s-c p-0-20">
							<view class="box" v-for="(imgs, img_num) in item.image" :key="img_num">
								<image style="width: 100rpx;height: 100rpx;" @click="openImg(item.image,imgs.file_path)"
									:src="imgs.file_path" mode="aspectFill" width=""></image>
							</view>
						</view>
					</view>
					<!-- 没有记录 -->
					<view class="d-c-c p30" v-if="tableData.length ==0 ">
						<view class="none-data-box">
							<image src="/static/none.png" mode="widthFix"></image>
							<text>亲，暂无评价哦</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view style="width: 100%;height: 200rpx;">

		</view>
		<view class="btn_bottom">
			<!-- <button class="person" open-type="im" bindim="onimError" data-im-id='1225213885'>客服</button> -->
			<button open-type="contact" session-from="sessionFrom" class="person">客服</button>
			<view class="buy" @click="buy()">立即下单</view>
		</view>
	</view>
</template>

<script>
	import share from '@/common/share.js'
	export default {
		mixins: [share],
		data() {
			return {
				product_id: '',
				product_sales: 0,
				info: {},
				dyh: 'https://jiechendy.sdshengyue.cn/uploads/fb/fe32ff72c26b5552badee43ebf0736.png',
				btn_status: -1,
				btn_status1: 0,
				buy_data: {},
				categoryData: [{
					id: 1,
					name: '团购详情'
				}, {
					id: 2,
					name: '用户评价'
				}],
				show_box: true,
				state_active: -1,
				page: 1,
				list_rows: 15,
				tableData: [],
				product_detail: {}
			};
		},
		methods: {
			change(val, key) {
				this.tableData = []
				if (this.btn_status != -1) {
					let _this = this;
					let product_id = _this.buy_data.product_id;
					_this.btn_status1 = val
					_this.show_box = !_this.show_box
					_this._get(
						'product.comment/lists', {
							product_id: product_id,
							scoreType: _this.state_active,
							page: _this.page,
							list_rows: _this.list_rows
						},
						function(res) {
							console.log(res, 'res');
							_this.tableData = _this.tableData.concat(res.data.list.data);
						}
					);


				} else {
					uni.showToast({
						title: '请选择商品',
						icon: 'none'
					})
				}

			},
			getData() {
				let self = this;
				self._get(
					'product.product/twonewlists', {
						category_id: self.product_id,
						visitcode: self.getVisitcode()
					},
					function(res) {
						self.info = res.data
						self.product_detail = res.data.shuju.data[0]
						self.product_id = self.product_detail.product_id
						self.btn_status = 0
						self.buy_data = self.product_detail.sku[0]
					}
				);
			},
			changeClass(index, val) {
				this.product_detail = val
				this.btn_status = index
				this.btn_status1 = 0
				this.show_box = true
				this.buy_data = val.sku[0]
				this.product_sales = val.product_salesd
				console.log('this.buy_data', val);
				let _this = this;
				_this._get(
					'product.comment/lists', {
						product_id: _this.buy_data.product_id,
						scoreType: _this.state_active,
						page: _this.page,
						list_rows: _this.list_rows
					},
					function(res) {
						console.log(res, 'res');
						_this.tableData = _this.tableData.concat(res.data.list.data);
					}
				);
			},
			buy() {
				if (this.btn_status == -1) {
					uni.showToast({
						title: '请选择服务',
						icon: 'none'
					})
					return false;
				}
				let url = '/pages/order/confirm-order?product_id=' + this.buy_data.product_id +
					'&product_num=1&product_sku_id=' + this.buy_data.spec_sku_id + '&order_type=buy';
				this.gotoPage(url)
			},
			openImg(list, img) {
				let arr = [];
				list.forEach((item, index) => {
					arr.push(item.file_path)
				})
				uni.previewImage({
					urls: arr,
					current: img,
					fail(err) {
						this.showError(err)
						console.log(err)
					}
				});
			},

		},
		onLoad(options) {
			this.product_id = options.id
			console.log(options.id);
			this.getData()
		},
		onimError(e) {
			console.log("拉起IM客服成功", e);
		},

	}
</script>

<style lang="scss">
	.fenlei {
		// position: fixed;
		width: 100%;
		height: 100rpx;
		background-color: #fff;
		z-index: 99;
		color: #999;
		display: flex;

		.father {
			width: 50%;
			height: 100rpx;
			position: relative;

			.son {
				width: 150rpx;
				height: 100rpx;
				text-align: center;
				line-height: 100rpx;
				margin: 0 auto;
				font-weight: bold;
			}
		}

	}

	.son_active {
		color: #2263B3;
	}

	.xian_active {
		width: 45rpx;
		height: 4rpx;
		background-color: #2263B3;
		position: absolute;
		left: 50%;
		transform: translate(-50%, 0);
		bottom: 20rpx;
	}

	.goods-list {
		width: 300rpx;
		height: 130rpx;
		border: 2px solid #F3F3F3;
		display: inline-block;
		border-radius: 20rpx;
		margin-right: 20rpx;
		padding: 20rpx 40rpx;
		font-size: 30rpx;
	}

	.goods_active {
		background-color: #E4EAFA;
		color: #2568BC;
	}

	.goods_boom {
		width: 100%;
		white-space: nowrap;

		padding: 20rpx;
	}

	.btn_bottom {
		position: fixed;
		width: 100%;
		height: 150rpx;
		background-color: #fff;
		bottom: 0;
		display: flex;
		padding-top: 20rpx;
	}

	.person {
		width: 230rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		border-radius: 50rpx;
		color: #fff;
		font-size: 32rpx;
		background: linear-gradient(-90deg, #DDAA69, #DEBC8F);
		margin: 0 40rpx;
	}

	.buy {
		width: 430rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		border-radius: 50rpx;
		color: #fff;
		font-size: 32rpx;
		background: linear-gradient(-90deg, #2264B4, #488BDB);
	}

	.goods_box {
		width: 100%;
		// height: 500rpx;
		background-color: #fff;
		overflow: hidden;
	}

	.hr {
		width: 95%;
		margin-left: 2.5%;
		height: 1rpx;
		background-color: #F8F8F8;
		margin-top: 10rpx;
	}

	.goods_detail {
		width: 100%;
		margin-top: 20rpx;
		background-color: #fff;
		// height: 300rpx;
	}

	.hr1 {
		width: 6%;
		margin-left: 47%;
		height: 2px;
		background-color: #2568BC;
	}

	.hr2 {
		width: 100%;
		height: 1rpx;
		background-color: #F8F8F8;
		margin: 10rpx 0;
	}

	.title {
		padding-top: 20rpx;
		width: 100%;
		text-align: center;
		font-size: 34rpx;
		color: #2568BC;
		margin-bottom: 10rpx;
	}

	.detail_box {
		width: 90%;
		margin-left: 5%;

		.txt {
			font-size: 32rpx;
			font-weight: bold;
			margin-top: 40rpx;
			margin-bottom: 20rpx;
		}
	}

	.order_box {
		width: 80rpx;
		height: 80rpx;
		border-radius: 10rpx;
		box-shadow: rgba(0, 0, 0, 0.35) 0px 1px 5px;
		text-align: center;
		font-size: 30rpx;
		padding: 10rpx;
	}

	.order_box_dyh {
		margin: 0 10rpx;
		height: 100rpx;
		text-align: center;
		padding-top: 35rpx;
	}

	.shop_name {
		width: 25%;
		font-size: 30rpx;
		color: #9F9F9F;
	}

	.shop_detail {
		width: 75%;
		font-size: 30rpx;
	}

	.look-evaluate .comment-list {
		background: #ffffff;
	}

	.look-evaluate .comment-list .item {
		padding-top: 30rpx;
		padding-bottom: 30rpx;
		border-top: none;
		border-bottom: 1px solid #dddddd;
	}

	.look-evaluate .iconfont {
		border-radius: 50%;
		font-size: 40rpx;
		text-align: center;
	}

	.look-evaluate .icon-pingjiahaoping {
		color: #f42222;
	}

	.look-evaluate .icon-pingjiazhongping {
		color: #f2b509;
	}

	.look-evaluate .icon-pingjiachaping {
		color: #999999;
	}

	.look-evaluate .imgs {
		flex-wrap: wrap;
	}

	.look-evaluate .imgs .box {
		margin-top: 10rpx;
		margin-right: 10rpx;
	}

	.look-evaluate .imgs .box:nth-child(3n) {
		margin-right: 0;
	}

	.look-evaluate .imgs .box,
	.look-evaluate .imgs .box image {
		width: 210rpx;
		height: 210rpx;
	}

	.popimg {
		position: fixed;
		width: 750rpx;
		height: 100vh;
		background-color: #000000;
		top: 0;
		left: 0;
		z-index: 2000;
	}

	.icon-start {
		color: #f5a623;
	}
</style>